bool cmp(int a,int b){
    return a>b;
}

class Solution {

public:
    long long maximumHappinessSum(vector<int>& happiness, int k) {
        long long ans=0;
        sort(happiness.begin(),happiness.end(),cmp);
        for(int i=0;i<k;i++){
            happiness[i]-=i;
            if(happiness[i]>0){
                ans+=happiness[i];
            }else{
                break;
            }

        }



        return ans;
    }
};